package org.snia.cdmi.model;

import java.io.InputStream;
import java.util.Date;
import java.util.List;

public class InputDataObject {

    private static final long serialVersionUID = -2883501141593631181L;

    /** The key under which this object is stored */
    private String objURI = null;
    
    /** The name of the bucket in which this object is contained */
    private String containerName = null;
    
    /** The name of the bucket in which this object is contained */
    private String prefix = null;
    
    /** The metadata stored by System for this object */
    private UserMetadata metadata = new UserMetadata();

    /** The stream containing the contents of this object from System */
    private InputStream objectContent;

    /** 对象的大小 */
    private long length;
    
    /** 对象的最新的版本号 */
    private String version;
    
    /** 对象的最后一次修改时间 */
    private Date lastModifiedTime;
    
    /** 对象返回的地址 */
    private String location;
    
    /** 对象在容器中的存储位置 */
	private String path;
	
//	/** 是否是最后一片 */
//	private boolean isLastSlice = true;
	
	/** 片文件相对整个文件的起始位置 */
	private long offset = 0;
	
	/** 访问该数据对象的授权码 */
	private String accessKey;
	
	/** 存储的类型 */
	private List<StoreClass> storeClasses;

	/** 压缩模式 */
	private ZipMode zipMode;
	
	/** 对象的MD5值 */
	private String md5;
	
    public String getPrefix() {
		return prefix;
	}

	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}
	
    public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

    public InputStream getObjectContent() {
		return objectContent;
	}

	public void setObjectContent(InputStream objectContent) {
		this.objectContent = objectContent;
	}

	public long getLength() {
		return length;
	}

	public void setLength(long length) {
		this.length = length;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public Date getLastModifiedTime() {
		return lastModifiedTime;
	}

	public void setLastModifiedTime(Date lastModifiedTime) {
		this.lastModifiedTime = lastModifiedTime;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public void setUserMetadata(UserMetadata metadata) {
		this.metadata = metadata;
	}

	/**
     * Gets the metadata stored by Amazon S3 for this object. The
     * {@link ObjectMetadata} object includes any custom user metadata supplied by the
     * caller when the object was uploaded, as well as HTTP metadata such as
     * content length and content type.
     * 
     * @return The metadata stored by Amazon S3 for this object.
     * 
     * @see S3Object#getObjectContent()
     */
    public UserMetadata getUserMetadata() {
        return metadata;
    }

    /**
     * Gets an input stream containing the contents of this object. Callers
     * should close this input stream as soon as possible, because the
     * object contents aren't buffered in memory and stream directly from Amazon
     * S3.
     * 
     * @return An input stream containing the contents of this object.
     * 
     * @see S3Object#getObjectMetadata()
     * @see S3Object#setObjectContent(InputStream)
     */
    public InputStream getContent() {
        return objectContent;
    }

    /**
     * Sets the input stream containing this object's contents.
     * 
     * @param objectContent
     *            The input stream containing this object's contents.
     *            
     * @see S3Object#getObjectContent()        
     */
    public void setContent(InputStream objectContent) {
        this.objectContent = objectContent;
    }

    /**
     * Gets the name of the bucket in which this object is contained.
     * 
     * @return The name of the bucket in which this object is contained.
     * 
     * @see S3Object#setBucketName(String)     
     */
    public String getContainerName() {
        return containerName;
    }

    /**
     * Sets the name of the bucket in which this object is contained.
     * 
     * @param bucketName
     *            The name of the bucket containing this object.
     *            
     * @see S3Object#getBucketName()      
     */
    public void setContainerName(String containerName) {
        this.containerName = containerName;
    }

    /**
     * Gets the key under which this object is stored.
     * 
     * @return The key under which this object is stored.
     * 
     * @see S3Object#setKey(String)
     */
    public String getObjectUri() {
        return this.objURI;
    }

    /**
     * Sets the key under which this object is stored.
     * 
     * @param key
     *            The key under which this object is stored.
     *            
     * @see S3Object#getKey()           
     */
    public void setObjectUri(String objURI) {
        this.objURI = objURI;
    }
    
    /**
     * @see java.lang.Object#toString()
     */
    @Override
	public String toString() {
        return "DataObject [object URI=" + getObjectUri() 
            + ",container=" + (containerName == null ? "<Unknown>" : containerName)  
            + "]";
    }

	/**
	 * @param accessKey the accessKey to set
	 */
	public void setAccessKey(String accessKey) {
		this.accessKey = accessKey;
	}

	/**
	 * @return the accessKey
	 */
	public String getAccessKey() {
		return accessKey;
	}

	/**
	 * @param md5 the md5 to set
	 */
	public void setMd5(String md5) {
		this.md5 = md5;
	}

	/**
	 * @return the md5
	 */
	public String getMd5() {
		return md5;
	}

//	/**
//	 * @param isLastSlice the isLastSlice to set
//	 */
//	public void setLastSlice(boolean isLastSlice) {
//		this.isLastSlice = isLastSlice;
//	}
//
//	/**
//	 * @return the isFirstSlice
//	 */
//	public boolean isLastSlice() {
//		return this.isLastSlice;
//	}
	/**
	 * @param offset the offset to set
	 */
	public void setOffset(long offset) {
		this.offset = offset;
	}

	/**
	 * @return the offset
	 */
	public long getOffset() {
		return offset;
	}
	
	/**
	 * @param storeClass the storeClass to set
	 */
	public void setStoreClasses(List<StoreClass> storeClasses) {
		this.storeClasses = storeClasses;
	}

	/**
	 * @return the storeClass
	 */
	public List<StoreClass> getStoreClasses() {
		return storeClasses;
	}
	
	/**
	 * @param zipMode the zipMode to set
	 */
	public void setZipMode(ZipMode zipMode) {
		this.zipMode = zipMode;
	}

	/**
	 * @return the zipMode
	 */
	public ZipMode getZipMode() {
		return zipMode;
	}
}
